#include "mycard.h"

mycard::mycard(QWidget *parent)
    : QWidget{parent}
{
   isfront=false;
}

void mycard::setImage(QPixmap &front,QPixmap &back)
{
    m_front=front;
    m_back=back;

    setFixedSize(m_back.size());

    update();
}

QPixmap mycard::getImage()
{
    return m_front;
}

void mycard::setfront(bool flag)
{
    isfront=flag;
}

bool mycard::isFrontSide()
{
    return isfront;
}

void mycard::setcard(card &card)
{
    m_card=card;
}

card mycard::getcard()
{
    return m_card;
}

void mycard::mousePressEvent(QMouseEvent *event)
{
    if(isfront)
    {
        //正面执行卡牌效果
    }
    else
    {
        isfront=true;
    }
    update();
}

void mycard::paintevent(QPaintEvent *event)
{
    QPainter p(this);
    if(isfront)
    {
        p.drawPixmap(rect(),m_front);
    }
    else
    {
        p.drawPixmap(rect(),m_back);
    }
}


